from django.db.models.signals import post_save
from django.dispatch import receiver

from apps.client.models import Client
from apps.document.models import DocumentAndForms, ClientDocuments
from apps.document.types import DocumentType
from apps.users.models import Provider


def save_soap_note(instance):
    content = [
        {
            "type": 1,
            "option": [],
            "question": "Subjective Complaint",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Objective Findings",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Assessment of Progress",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Plans for Next Session",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="SOAP",
                                    type=2,
                                    content=content)


def save_dap_note(instance):
    content = [
        {
            "type": 1,
            "option": [],
            "question": "Data",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Assessment and Response",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Plan",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="DAP",
                                    type=2,
                                    content=content)


def save_treatment_plan(instance):
    content = [
        {
            "type": 3,
            "option": [
                {
                    "answer": "Individual",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Group",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Family",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Couple",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Type of sessions:",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Weekly",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Bi-Weekly",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Monthly",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Frequency of sessions:",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Mood / Affect - significant changes reported?",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Thought process / Orientation  - significant changes reported?",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Behavior / Functioning  - significant changes reported?",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Medical condition  - significant changes reported?",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "N/A",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Substance use  - significant changes reported?",
            "required": True
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Notable",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Risk assessment",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "New issue presented today?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Self report of progress towards goals / objectives since last session:",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Progress toward long-term goals",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "1. What actions has client taken to meet their long-term goals?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "2. Which plans were carried out by client to meet their long-term goals?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "3. Which interventions were used?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "4. If client has not made progress, what is keeping client from making long-term goals?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Progress toward short-term goals",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "1. What actions has client taken to meet their short-term goals?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "2. Which plans were carried out by client to meet their short-term goal?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "3. Which interventions were used?",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "4. If client has not made progress, what is keeping client from making short-term goals?",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="Treatment Plan Note",
                                    type=2,
                                    content=content)


def save_progress_note(instance):
    content = [
        {
            "type": 1,
            "option": [],
            "question": "Overall Notes",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Cognitive Functioning",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Affect",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Interpersonal",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Functional Status",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "None",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Suicidal Ideation",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Homicidal Indeation",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Risk Factors",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Medications",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Current Functioning, Symptoms, or Impairments",
            "required": True
        },
        {
            "type": 1,
            "option": [],
            "question": "Content or Topics Discussed",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="Progress Notes",
                                    type=2,
                                    content=content)


def save_gad_note(instance):
    content = [
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Feeling nervous, anxious, or on edge.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Not being able to stop or control worrying?",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Worrying too much about different things.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "4. Trouble relaxing.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "5. Being so restless that it's hard to sit still.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "6. Becoming easily annoyed or irritable.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Over half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "7. Feeling afraid as if something awful might happen.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not difficult at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Somewhat difficult",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Very difficult",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Extremely difficult",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "8. If you checked off any problems, how difficult have these made it for you to do your "
                        "work, take care of things at home, or get along with other people?",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="GAD",
                                    type=1,
                                    content=content)


def save_intake_questionnaire(instance):
    content = [
        {
            "type": 1,
            "option": [],
            "question": "What brings you to counseling at this time? Is there something specific, such as "
                        "particular event? Be as detailed as you can",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "What are your goals for counseling?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Have you seen a mental health professional before?",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "Specify all medications and supplements you are presently taking and for what reason?",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "If taking prescription medication, who is your prescribing MD? Please include type of MD, "
                        "name and phone number.",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "Who is your primary care physician? Please include type of MD, name and phone number.",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Do you drink alcohol?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Do you use recreational drugs?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Do you have suicidal thoughts?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Have you ever attempted suicide?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Do you have thoughts or urges to harm others?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Have you ever been hospitalized for a psychiatric issue?",
            "required": False
        },
        {
            "type": 4,
            "option": [
                {
                    "answer": "Yes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "No",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Is there history of mental illness in your family?",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "If you are in a relationship, please describe the nature of the relationship and months or years together.",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "Describe your current living situation. Do you live alone, with others, with family etc...",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "What is your level of education? Highest grade/degree and type of degree.",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "What is your current occupation? What do you do? How long have you been doing it?",
            "required": False
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Headache",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "High blood pressure",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Gastritis or esophagitis",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Hormone-related problems",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Head injury",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Angina or chest pain",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Irritable bowel",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Chronic pain",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Loss of consciousness",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Heart attack",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Bone or joint problems",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Seizures",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Kidney-related issues",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Chronic fatigue",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Dizziness",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Faintness",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Heart valve problems",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Urinary tract problems",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Fibromyalgia",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Numbness and tingling",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Shortness of breath",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Diabetes",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Hepatitis",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Asthma",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Athritis",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Thyroid issues",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "HIV/AIDS",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Cancer",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Please check any of the following that apply",
            "required": False
        },
        {
            "type": 1,
            "option": [],
            "question": "What else would you like me to know?",
            "required": False
        }
    ]
    DocumentAndForms.objects.create(title="Intake Questionnaire",
                                    type=1,
                                    content=content)


def save_patient_health_questionnaire(instance):
    content = [
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "1. Little interest or pleasuring in doing things",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "2. Feeling down, depressed or hopeless.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "3. Trouble falling or staying asleep, or sleeping too much.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "4. Feeling tired or having little energy.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "5. Poor appetite or overeating.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "6. Feeling bad about yourself - or that you are a failure or have let yourself or your "
                        "family down",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "7. Trouble concentrating on things, such as reading the newspaper or watching television.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "8. Moving or speaking so slowly that other people could have noticed. Or the opposite - "
                        "being so fidgety or restless that you have been moving around a lot more than usual.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Several days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "More than half the days",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Nearly every day",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "9. Thoughts that you would better off dead or of hurting yourself in some way.",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Not difficult at all",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Somewhat difficult",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Very difficult",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Extremely difficult",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "If you checked off any problem on this questionnaire so far, how difficult have these "
                        "problems made it for you to do your work, take care of things at home, or get along with "
                        "other people?",
            "required": True
        }
    ]
    DocumentAndForms.objects.create(title="PATIENT HEALTH QUESTIONNAIRE-9 (PHQ-9)",
                                    type=1,
                                    content=content)


def save_release_of_information_consent(instance):
    content = [
        {
            "type": 2,
            "option": [],
            "question": "Client's name:",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Send",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Receive",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "I authorize {first_name} {last_name} to:".format(first_name=instance.provider.first_name,
                                                                          last_name=instance.provider.last_name),
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Medical history and evaluation(s)",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Mental health evaluations",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Development and/or social history",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Educational records",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Progress notes, and treatment or closing summary",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "The following information:",
            "required": False
        },
        {
            "type": 2,
            "option": [],
            "question": "To / From:",
            "required": False
        },
        {
            "type": 2,
            "option": [],
            "question": "Phone:",
            "required": False
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Self",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Parent/legal guardian",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Personal representative",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "Your relationship to client:",
            "required": True
        },
        {
            "type": 3,
            "option": [
                {
                    "answer": "Planning appropriate treatment or program",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Continuing appropriate treatment or program",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Determining eligibility for benefits or program",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Case review",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Updating files",
                    "answerType": "",
                    "answerDetail": ""
                },
                {
                    "answer": "Other",
                    "answerType": "",
                    "answerDetail": ""
                }
            ],
            "question": "The above information will be used for the following purposes:",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "I understand that this information may be protected by Title 45 (Code of Federal Rules of "
                        "Privacy of Individually Identifiable Health Information, Parts 160 and 164) and Title 42 ("
                        "Federal Rules of Confidentiality of Alcohol and Drug Abuse Patient Records, Chapter 1, "
                        "Part 2), plus applicable state laws. I further understand that the information disclosed to "
                        "the recipient may not be protected under these guidelines if they are not a health care "
                        "provider covered by state or federal rules.\nI understand that this authorization is "
                        "voluntary, and I may revoke this consent at any time by providing written notice, "
                        "and after (some states vary, usually 1 year) this consent automatically expires. I have been "
                        "informed what information will be given, its purpose, and who will receive the information. "
                        "I understand that I have a right to receive a copy of this authorization. I understand that "
                        "I have a right to refuse to sign this authorization.\nIf you are the legal guardian or "
                        "representative appointed by the court for the client, please attach a copy of this "
                        "authorization to receive this protected health information.\n\nSignature:",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Date:",
            "required": True
        },
        {
            "type": 2,
            "option": [],
            "question": "Witness signature (if client is unable to sign):",
            "required": False
        },
        {
            "type": 2,
            "option": [],
            "question": "Witness Date:",
            "required": False
        }
    ]
    DocumentAndForms.objects.create(title="Release of Information Consent",
                                    type=1,
                                    content=content)


# @receiver(post_save, sender=Client)
# def add_client_documents(sender, instance, *args, **kwargs):
#     if kwargs['created']:
#         documents = DocumentAndForms.objects.filter(type=str(DocumentType.INTAKE_FORMS.value),
#                                                     is_checked=True)
#         if documents.exists():
#             client_documents = []
#             for document in documents:
#                 client_document = ClientDocuments(
#                     client=instance,
#                     title=document.title,
#                     content=document.content
#                 )
#                 client_documents.append(client_document)
#             ClientDocuments.objects.bulk_create(client_documents)
